package com.cqupt.scanning.system.consumer.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cqupt.scanning.system.admin.entity.PatientFoot;
import com.cqupt.scanning.system.admin.entity.PatientThree;
import com.cqupt.scanning.system.consumer.service.ConsumerService;
import com.cqupt.scanning.system.utils.result.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Data: 2021/7/12 14:23
 * @Author: 宋宝梁
 */
@RestController
@RequestMapping("/consumer")
public class ConsumerController {

    private ConsumerService consumerService;

    @Autowired
    public ConsumerController(ConsumerService consumerService) {
        this.consumerService = consumerService;
    }

    /**
     * 获取当前设备的病人的数量
     * @return
     */
    @GetMapping("/statistics/getAllPatsCount")
    public R getAllPatsCount() {
        return consumerService.getAllPatsCount();
    }

    /**
     * 获取当前设备的病人信息
     * @param query
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/statistics/getAllPats")
    public R getAllPats(@RequestParam("query") String query,
                        @RequestParam(value = "pageNum", defaultValue = "1") Integer current,
                        @RequestParam(value = "pageSize", defaultValue = "10") Integer size) {
        return consumerService.getAllPats(query,current, size);
    }

    /**
     * 筛选并获取当前设备的病人信息(如果三维和步态显示的value类型相同就可以一起用，这主要是用来用户端的步态数据筛选与获取所有步态病人的信息)
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/statistics/queryAllPats")
    public R queryAllPats(@RequestParam(value = "name",required = false) String name,
                          @RequestParam(value = "age_lower",required = false) String ageLower,
                          @RequestParam(value = "age_upper",required = false) String ageUpper,
                          @RequestParam(value = "doctor",required = false) String doctor,
                          @RequestParam(value = "height_lower",required = false) String heightLower,
                          @RequestParam(value = "height_upper",required = false) String heightUpper,
                          @RequestParam(value = "measureMode",required = false) String measureMode,
                          @RequestParam(value = "sex",required = false) String sex,
                          @RequestParam(value = "weight_lower",required = false) String weightLower,
                          @RequestParam(value = "weight_upper",required = false) String weightUpper,
                          @RequestParam(value = "phone",required = false) String phone,
                          @RequestParam(value = "beginTime",required = false) String beginTime,
                          @RequestParam(value = "endTime",required = false) String endTime,
                          @RequestParam(value = "pageNum", defaultValue = "1") Integer current,
                          @RequestParam(value = "pageSize", defaultValue = "10") Integer size) {
        return consumerService.queryAllPats(name,ageLower,ageUpper,doctor,heightLower,heightUpper,measureMode,sex, weightLower,weightUpper, phone,beginTime,endTime ,current, size);
    }


//    /**
//     * 根据时间段获取当前设备的病人信息
//     * @param beginTime
//     * @param endTime
//     * @param current
//     * @param size
//     * @return
//     */
//    @GetMapping("/statistics/queryAllByTime")
//    public R queryAllByTime(@RequestParam(value = "beginTime") String beginTime,
//                            @RequestParam(value = "endTime") String endTime,
//                        @RequestParam(value = "pageNum", defaultValue = "1") Integer current,
//                        @RequestParam(value = "pageSize", defaultValue = "10") Integer size) {
//        return consumerService.queryAllByTime(beginTime,endTime,current, size);
//    }


    /**
     * 三维病人信息显示及筛选
     * @param current
     * @param size
     * @return
     */
    @GetMapping("/statistics/queryAllThrees")
    public R queryAllThrees(
            @RequestParam(value = "name",required = false) String name,
            @RequestParam(value = "sex",required = false) String sex,
            @RequestParam(value = "devNum",required = false) String devNum,
            @RequestParam(value = "business_name",required = false) String businessName,
            @RequestParam(value = "address",required = false) String address,
            @RequestParam(value = "city_province",required = false) String cityProvince,
            @RequestParam(value = "country",required = false) String country,
            @RequestParam(value = "phone",required = false) String phone,
            @RequestParam(value = "fax",required = false) String fax,
            @RequestParam(value = "age_lower",required = false) String ageLower,
            @RequestParam(value = "age_upper",required = false) String ageUpper,
            @RequestParam(value = "height_lower",required = false) String heightLower,
            @RequestParam(value = "height_upper",required = false) String heightUpper,
            @RequestParam(value = "weight_lower",required = false) String weightLower,
            @RequestParam(value = "weight_upper",required = false) String weightUpper,
            @RequestParam(value = "weight_bearing_lower",required = false) String weightBearingLower,
            @RequestParam(value = "weight_bearing_upper",required = false) String weightBearingUpper,
            @RequestParam(value = "dress_shoe",required = false) String dressShoe,
            @RequestParam(value = "athletic_shoe",required = false) String athleticShoe,
            @RequestParam(value = "casual_shoe",required = false) String casualShoe,
            @RequestParam(value = "heels",required = false) String heels,
            @RequestParam(value = "beginTime",required = false) String beginTime,
            @RequestParam(value = "endTime",required = false) String endTime,
            @RequestParam(value = "orgName",required = false) String orgName,
            @RequestParam(value = "doctor",required = false) String doctor,
            @RequestParam(value = "measureMode",required = false) String measureMode,
            @RequestParam(value = "pageNum", defaultValue = "1") Integer current,
            @RequestParam(value = "pageSize", defaultValue = "10") Integer size
    ) {
        Page<PatientThree> page = new Page<>(current, size);
        return consumerService.queryAllThrees(page,  name, ageLower, ageUpper, doctor, heightLower, heightUpper, measureMode, sex, weightLower, weightUpper, beginTime, endTime,phone,orgName,devNum,businessName,address,cityProvince,country,fax,
                weightBearingLower, weightBearingUpper,dressShoe,athleticShoe,casualShoe,heels);
    }
}

